package com.prs.crm.dao.purchase.impl;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.purchase.PaymentOrderDao;
import com.prs.crm.domain.purchase.PaymentOrder;
import com.prs.crm.domain.purchase.PurchaseOrder;

public class PaymentOrderDaoImpl extends BaseDaoImpl<PaymentOrder> implements
		PaymentOrderDao {

	@Override
	public PaymentOrder getPaymentOrder(Serializable id) {
		return this.getHibernateTemplate().get(PaymentOrder.class,id);
	}

	@Override
	public void saveOrUpdate(PaymentOrder paymentOrder) {
		this.getHibernateTemplate().saveOrUpdate(paymentOrder);		
	}

	@Override
	public List<PaymentOrder> getPaymentOrdersByOrder(
			PurchaseOrder purchaseOrder) {
		Criteria criteria=this.getSession().createCriteria(PaymentOrder.class);
		criteria.add(Restrictions.eq("purchaseOrder",purchaseOrder));
		return criteria.list();
	}

}
